package com.bdqn.ch07.service;

import com.bdqn.ch07.entity.Right;
import com.bdqn.ch07.entity.Role;
import com.bdqn.ch07.repository.RightRepository;
import com.bdqn.ch07.repository.RoleRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RoleServiceImp implements RoleService {

    @Resource
    RightRepository rightRepository;

    @Resource
    RoleRepository roleRepository;

    @Override
    public List<Role> findByRoleList() {
        return roleRepository.findAll();
    }

    @Override
    public List<Right> findAllRights() {
        return rightRepository.findAll();
    }

    @Override
    public List<Right> findRightsByRole(Role role) {
        return rightRepository.findRightsByRolesOrderByRightCode(role);
    }

}
